package goover.unit04;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileInputStreamDemo01 {
    public static void main(String[] args){
        FileInputStream in = null;
        FileOutputStream out = null;
        try {
            in = new FileInputStream("D:\\JAVA\\source\\src.jpg");
            out = new FileOutputStream("D:\\JAVA\\target\\src.jpg",true);
            int len = 0;
            byte[] buff = new byte[1024];
            while ((len = in.read(buff)) != -1){
                out.write(buff,0,len);
                out.flush();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                if(in != null){
                    in.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if(out != null){
                    out.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
